package com.weng.coder.service.convertor.impl.command;

import com.weng.coder.service.convertor.ConvertCommand;
import com.weng.coder.service.convertor.impl.ConvertedFile;

/**
 * 转换Maven配置
 *
 * @version 
 * @author wengzhonghui  2017年7月12日 上午11:20:30
 * 
 */
public class MavenCommand implements ConvertCommand {

    @Override
    public void process(ConvertedFile file, String code, String name) {
        if (file.getFromName().equals("pom.xml")) {
            file.replace("<groupId>cn.com.bmsoft.base</groupId>", "<groupId>cn.com.bmsoft." + code + "</groupId>");
            file.replace("<artifactId>base</artifactId>", "<artifactId>" + code + "</artifactId>");
            file.replace("<name>base</name>", "<name>" + code + "</name>");
            file.replace("base-common", code + "-common");
            file.replace("base-domain", code + "-domain");
            file.replace("base-dao", code + "-dao");
            file.replace("base-service", code + "-service");
            file.replace("base-web", code + "-web");
            file.replace("path=\"/base\"", "path=\"/" + code + "\"");
            file.replace("<finalName>base</finalName>", "<finalName>" + code + "</finalName>");
            file.replace("<contextPath>/base</contextPath>", "<contextPath>/" + code + "</contextPath>");
            file.replace("cn.com.bmsoft.base", "cn.com.bmsoft." + code);

            file.replace("<module>" + code + "-common</module>", "<module>base-common</module>");
            file.replace("<module>" + code + "-domain</module>", "<module>base-domain</module>");
            file.replace("<module>" + code + "-dao</module>", "<module>base-dao</module>");
            file.replace("<module>" + code + "-service</module>", "<module>base-service</module>");
            file.replace("<module>" + code + "-web</module>", "<module>base-web</module>");
        }
    }
}
